%% -*- mode: erlang -*-
%% This config file is the very basic config to compile emqx
%% This allows emqx to be used as a dependency for other applications
%% such as emqx module/plugin developments and tests.

%% With the help of EMQX's rebar3 fork, the config is extended
%% with rebar.config.erl module. Final result is written to
%% rebar.config.rendered if environment DEBUG is set.

{edoc_opts, [{preprocess, true}]}.
{erl_opts, [
    warn_unused_vars,
    warn_shadow_vars,
    warn_unused_import,
    warn_obsolete_guard,
    compressed,
    nowarn_unused_import,
    {d, snk_kind, msg}
]}.

{xref_checks, [
    undefined_function_calls,
    undefined_functions,
    locals_not_used,
    deprecated_function_calls,
    warnings_as_errors,
    deprecated_functions
]}.

%% Check the forbidden mnesia calls:
{xref_queries, [
    {"E || \"mnesia\":\"dirty_delete.*\"/\".*\" : Fun", []},
    {"E || \"mnesia\":\"transaction\"/\".*\" : Fun", []},
    {"E || \"mnesia\":\"async_dirty\"/\".*\" : Fun", []},
    {"E || \"mnesia\":\"clear_table\"/\".*\" : Fun", []},
    {"E || \"mnesia\":\"create_table\"/\".*\" : Fun", []},
    {"E || \"mnesia\":\"delete_table\"/\".*\" : Fun", []}
]}.

{dialyzer, [
    {warnings, [unmatched_returns, error_handling]},
    {exclude_mods, [
        emqx_exproto_v_1_connection_unary_handler_bhvr,
        emqx_exproto_v_1_connection_handler_client,
        emqx_exproto_v_1_connection_handler_bhvr,
        emqx_exproto_v_1_connection_adapter_client,
        emqx_exproto_v_1_connection_adapter_bhvr,
        emqx_exproto_v_1_connection_unary_handler_client,
        emqx_exhook_v_2_hook_provider_client,
        emqx_exhook_v_2_hook_provider_bhvr,
        'DurableMessage'
    ]},
    {plt_location, "."},
    {plt_prefix, "emqx_dialyzer"},
    {plt_apps, all_apps},
    {statistics, true}
]}.

{cover_opts, [verbose]}.
{cover_export_enabled, true}.
{cover_excl_mods,
    %% generated protobuf modules
    [
        emqx_exproto_pb,
        emqx_exhook_pb,
        %% taken almost as-is from OTP
        emqx_ssl_crl_cache
    ]}.

%{provider_hooks, [{pre, [{release, {relup_helper, gen_appups}}]}]}.

{post_hooks, []}.

{deps, [
    {lc, {git, "https://github.com/emqx/lc.git", {tag, "0.3.4"}}},
    {redbug, {git, "https://github.com/emqx/redbug", {tag, "2.0.10"}}},
    {gpb, "4.21.1"},
    {typerefl, {git, "https://github.com/ieQu1/typerefl", {tag, "0.9.6"}}},
    {gun, "2.1.0"},
    {ehttpc, {git, "https://github.com/emqx/ehttpc", {tag, "0.7.1"}}},
    {gproc, {git, "https://github.com/emqx/gproc", {tag, "0.9.0.1"}}},
    {jiffy, "1.1.2"},
    {cowlib, "2.13.0"},
    {ranch, {git, "https://github.com/emqx/ranch", {tag, "1.8.1-emqx-1"}}},
    {cowboy, {git, "https://github.com/emqx/cowboy", {tag, "2.9.2"}}},
    {esockd, {git, "https://github.com/emqx/esockd", {tag, "5.13.0"}}},
    {rocksdb, {git, "https://github.com/emqx/erlang-rocksdb", {tag, "1.8.0-emqx-6"}}},
    {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.21.0"}}},
    {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "3.4.1"}}},
    {grpc, {git, "https://github.com/emqx/grpc-erl", {tag, "0.7.1"}}},
    {minirest, {git, "https://github.com/emqx/minirest", {tag, "1.4.4"}}},
    {ecpool, {git, "https://github.com/emqx/ecpool", {tag, "0.6.1"}}},
    {replayq, {git, "https://github.com/emqx/replayq.git", {tag, "0.3.12"}}},
    {emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.14.0"}}},
    {rulesql, {git, "https://github.com/emqx/rulesql", {tag, "0.2.1"}}},
    % NOTE: depends on recon 2.5.x
    {observer_cli, "1.8.2"},
    {system_monitor, {git, "https://github.com/ieQu1/system_monitor", {tag, "3.0.6"}}},
    {getopt, "1.0.2"},
    {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "1.0.10"}}},
    {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.45.1"}}},
    {emqx_http_lib, {git, "https://github.com/emqx/emqx_http_lib.git", {tag, "0.5.3"}}},
    {sasl_auth, "2.3.3"},
    {jose, {git, "https://github.com/potatosalad/erlang-jose", {tag, "1.11.2"}}},
    {telemetry, "1.3.0"},
    {hackney, {git, "https://github.com/emqx/hackney.git", {tag, "1.18.1-1"}}},
    %% to keep in sync with mix.exs
    {ssl_verify_fun, "1.1.7"},
    %% in conflict by erlavro and rocketmq
    {jsone, {git, "https://github.com/emqx/jsone.git", {tag, "1.7.1"}}},
    {uuid, {git, "https://github.com/okeuday/uuid.git", {tag, "v2.0.6"}}},
    {bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {tag, "0.6.3"}}},
    {ra, {git, "https://github.com/emqx/ra", {tag, "v2.15.2-emqx-3"}}}
]}.

{xref_ignores,
    %% schema registry is for enterprise
    [
        {emqx_schema_registry, get_all_schemas, 0},
        {emqx_schema_api, format_schema, 1},
        {emqx_schema_api, make_schema_params, 1},
        {emqx_schema_parser, decode, 3},
        {emqx_schema_parser, encode, 3},
        {emqx_schema_registry, add_schema, 1},
        {emqx_audit, log, 2},
        % generated code for protobuf
        emqx_exhook_pb,
        % generated code for protobuf
        emqx_exproto_pb,
        % maybe BUILD_WITHOUT_QUIC
        emqx_quic_connection,
        quicer_listener
    ]}.

{eunit_opts, [verbose, {print_depth, 100}]}.

{project_plugins, [
    {erlfmt, "1.6.0"},
    {rebar3_hex, "7.0.2"}
]}.
